package com.webreport.dao.hibernate;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.webreport.dao.UserDao;
import com.webreport.exception.DaoException;
import com.webreport.model.QueryModel;
import com.webreport.model.db.User;
import com.webreport.utils.DaoUtils;
@Repository
public class UserDaoHibernate extends GenericDaoHibernate<User,String> implements UserDao{

	public UserDaoHibernate() {
		super(User.class);
	}
	public User queryByUsername(String username) throws DaoException{
		QueryModel query = new QueryModel(User.class.getName(),"username =:username");
		query.addParam("username", username);
		List<User> users = DaoUtils.queryHQL(getHibernateTemplate(), query);
		if (users != null && users.size() >0){
			return users.get(0);
		}else{
			return null;
		}
	}
}
